<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<html>
  <head>
    <title>Repeating Groups</title>
    <link href="../style.css" rel="stylesheet" type="text/css">
  </head>
  <body>
  <div class="header">
<h1>QuickFIX/J User Manual</h1>
</div>

    <H2>Repeating Groups</H2>
    QuickFIX has the ability to send messages containing repeating groups and even recursive
    repeating groups. All repeating groups begin with a field that indicates how many repeating
    groups are in a set. A group can be created by referencing a class named after this field
    scoped within the parent message or group.

    <H3>Creating Messages With Repeating Groups</H3>

    <p>
    Here is an example of a message that distributes market data. When the message is created
    the required field with the number of repeating groups is set to zero. This is because
    QuickFIX will automatically set this field for you when you add groups. This way there is
    never an inconsistancy between the number of entries in the field and in the message.
    </p>

    <pre class="code">package quickfix;

quickfix.fix42.MarketDataSnapshotFullRefresh message =
  new quickfix.fix42.MarketDataSnapshotFullRefresh(new Symbol("QF"));

quickfix.fix42.MarketDataSnapshotFullRefresh.NoMDEntries group =
  new quickfix.fix42.MarketDataSnapshotFullRefresh.NoMDEntries();

group.set(new MDEntryType('0'));
group.set(new MDEntryPx(12.32));
group.set(new MDEntrySize(100));
group.set(new OrderID("ORDERID"));
message.addGroup(group);

group.set(new MDEntryType('1'));
group.set(new MDEntryPx(12.32));
group.set(new MDEntrySize(100));
group.set(new OrderID("ORDERID"));
message.addGroup(group);</PRE>

    <H3>Reading Messages With Repeating Groups</H3>

    <p>
    To pull a group out of a message you need to supply the group you wish to pull out. You should
    first inspect the number of entries field (which the group is named after) to get the total number
    of groups. The message that was created above is now parsed back out below.
    </p>

    <pre class="code">package quickfix;

NoMDEntries noMDEntries = new NoMDEntries();
message.get(noMDEntries);
quickfix.fix42.MarketDataSnapshotFullRefresh.NoMDEntries group =
  new quickfix.fix42.MarketDataSnapshotFullRefresh.NoMDEntries();
MDEntryType MDEntryType = new MDEntryType();
MDEntryPx MDEntryPx = new MDEntryPx();
MDEntrySize MDEntrySize = new MDEntrySize();
OrderID orderID = new OrderID();

message.getGroup(1, group);
group.get(MDEntryType);
group.get(MDEntryPx);
group.get(MDEntrySize);
group.get(orderID);

message.getGroup(2, group);
group.get(MDEntryType);
group.get(MDEntryPx);
group.get(MDEntrySize);</PRE>

<div class="footer">More information at <a href="http://www.quickfixj.org/">www.quickfixj.org</a></div>

  </body>
</html>
